﻿using Autofac;
using EventHandlerDemo.Domain.Bases;
using EventHandlerDemo.Domain.OrderAttachments;
using EventHandlerDemo.Domain.OrderEventLogs;
using EventHandlerDemo.Domain.Orders;
using EventHandlerDemo.Infrastructure.EFCore;
using EventHandlerDemo.Infrastructure.Interceptors;
using EventHandlerDemo.Infrastructure.Repositories.OrderAttachments;
using EventHandlerDemo.Infrastructure.Repositories.OrderEventLogs;
using EventHandlerDemo.Infrastructure.Repositories.Orders;

namespace EventHandlerDemo.Infrastructure
{
    public class InfrastructureModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<OrderRepository>().As<IOrderRepository>().InstancePerLifetimeScope();
            builder.RegisterType<OrderEventLogRepository>().As<IOrderEventLogRepository>().InstancePerLifetimeScope();
            builder.RegisterType<OrderAttachmentRepository>().As<IOrderAttachmentRepository>().InstancePerLifetimeScope();
            builder.RegisterType<EFCoreUnitOfWork>().As<IUnitOfWork>().InstancePerLifetimeScope();
            builder.RegisterType<UowTransactionInterceptor>().InstancePerLifetimeScope();
            builder.RegisterType<UowTransactionAsyncInterceptor>().InstancePerLifetimeScope();
        }
    }
}
